package io.gitee.mingbaobaba.apijson.querycondition.query.properties;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.NotBlank;
import java.time.Duration;

/**
 * <p>数仓服务配置</p>
 *
 * @author yingsheng.ye
 * @version 1.0.0
 * @since 2023/6/20 21:46
 */
@Data
@Validated
@ConfigurationProperties(prefix = "datawarehouse")
public class ApiJsonQueryProperties {

    /**
     * 客户端ID
     */
    @NotBlank(message = "datawarehouse.client-id不能为空")
    private String clientId;

    /**
     * 客户端密钥
     */
    @NotBlank(message = "datawarehouse.client-secret不能为空")
    private String clientSecret;

    /**
     * 授权类型
     */
    private String grantType = "client_credentials";

    /**
     * 授权范围
     */
    private String scope = "all";

    /**
     * 请求token地址
     */
    @NotBlank(message = "datawarehouse.token-url不能为空")
    private String tokenUrl = "http://localhost:8080/oauth/token";

    /**
     * 服务调用地址
     */
    @NotBlank(message = "datawarehouse.service-url不能为空")
    private String serviceUrl = "http://localhost:8080/get";

    /**
     * HTTP连接超时时间
     */
    private Duration connectTimeout = Duration.ofSeconds(5);

    /**
     * HTTP读取超时时间
     */
    private Duration readTimeout = Duration.ofSeconds(30);

    /**
     * HTTP写入超时时间
     */
    private Duration writeTimeout = Duration.ofSeconds(30);

    /**
     * 是否启用token缓存
     */
    private boolean enableTokenCache = true;

}
